package ciyuanwutuobang.Core;

import ciyuanwutuobang.Entity.PlayerInfo;
import ciyuanwutuobang.MainClass;
import org.bukkit.configuration.file.FileConfiguration;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 150149
 */
public class Config {

    public double max_walk_kick_speed;
    public double max_swim_kick_speed;
    public double max_drive_kick_speed;
    public double max_ice_kick_speed;
    public double ignore_when_y_move;
    public int max_kick_count;
    public int max_move_packet_count;
    public int max_ban_count;
    public String kick_message;
    public String ban_message;
    public List<Integer> special_items;
    public List<Double> max_special_items_speed;

    private FileConfiguration config;
    private MainClass mainClass;

    public Config(FileConfiguration config,MainClass mainClass) {
        this.config = config;
        this.mainClass = mainClass;
        this.load();
    }

    private void load() {
        config.addDefault("maxWalkKickSpeed",7.7);
        config.addDefault("maxSwimKickSpeed",3);
        config.addDefault("maxDriveKickSpeed",24.8);
        config.addDefault("maxIceKickSpeed",12);
        config.addDefault("ignoreWhenYMove",8);
        config.addDefault("maxKickCount",4);
        config.addDefault("maxBanCount",3);
        config.addDefault("maxMovePacketCount",12);
        config.addDefault("kickMessage","检测到你的移动速度异常！");
        config.addDefault("banMessage","速度异常次数过多！已封禁");
        config.addDefault("specialItems.ID",new ArrayList<>());
        config.addDefault("specialItems.maxSpeed",new ArrayList<>());

        this.config.options().copyDefaults(true);
        mainClass.saveConfig();

        max_walk_kick_speed = this.config.getDouble("maxWalkKickSpeed");
        max_swim_kick_speed = this.config.getDouble("maxSwimKickSpeed");
        max_drive_kick_speed = this.config.getDouble("maxDriveKickSpeed");
        max_ice_kick_speed = this.config.getDouble("maxIceKickSpeed");
        ignore_when_y_move = this.config.getDouble("ignoreWhenYMove");
        max_kick_count = this.config.getInt("maxKickCount");
        max_ban_count = this.config.getInt("maxBanCount");
        max_move_packet_count = this.config.getInt("maxMovePacketCount");
        kick_message = this.config.getString("kickMessage");
        ban_message = this.config.getString("banMessage");
        special_items = this.config.getIntegerList("specialItems.ID");
        max_special_items_speed = this.config.getDoubleList("specialItems.maxSpeed");
    }

}
